package com.sskj.api.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sskj.api.domain.UserLoginLog;
import com.sskj.api.mapper.UserLoginLogMapper;
import com.sskj.api.service.IUserLoginLogService;
import com.sskj.api.vo.req.UserLoginLogReq;
import com.sskj.common.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class UserLoginLogService extends ServiceImpl<UserLoginLogMapper, UserLoginLog> implements IUserLoginLogService {

    @Override
    public IPage<UserLoginLog> pageList(UserLoginLogReq req) {
        if (StrUtil.isNotBlank(req.getStartDate()) && StrUtil.isNotBlank(req.getEndDate())) {
            req.setStartDate(req.getStartDate() + " 00:00:00");
            req.setEndDate(req.getEndDate() + " 23:59:59");
        }

        IPage<UserLoginLog> pageConfig = new Page<>(req.getPageNum(), req.getPageSize());
        return baseMapper.pageList(pageConfig, req);
    }
}
